package com.baicaoyuan.web.enums;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;

@RequiredArgsConstructor
@Getter
public enum ProjectBelongEnum {

    /**
     * 普通项目
     */
    NORMAL("1"),

    /**
     * 信用卡
     */
    CREDIT_CARD("2"),

    /**
     * pos机
     */
    POS("3");

    private final String status;

    /**
     * 根据标识获取枚举
     *
     * @param belong
     * @return
     */
    public static ProjectBelongEnum acquire(final String belong) {
        Optional<ProjectBelongEnum> belongEnum = Arrays.stream(ProjectBelongEnum.values())
                .filter(v -> Objects.equals(v.getStatus(), belong))
                .findFirst();
        return belongEnum.orElse(ProjectBelongEnum.NORMAL);
    }

}
